'''
给你一棵二叉树，请你用遍历的思路写一个 traverse 函数，打印出遍历这棵二叉树的过程
'''

class TreeNode:
    def __init__(self,val,left,right):
        self.val = val
        self.left = left
        self.right = right

def traverse(root):
    if root is None:
        return 
    print("从节点 %s 进入节点 %s", root, root.left)
    traverse(root.left)
    print("从节点 %s 回到节点 %s", root.left, root);

    print("从节点 %s 进入节点 %s", root, root.right);
    traverse(root.right)
    print("从节点 %s 回到节点 %s", root.right, root);

'''
从二叉树进阶成多叉树
'''
class Node:
    def __init__(self,val,chirdren) -> None:
        self.val = val
        self.chirdren = chirdren

    def traverse(root,chirdren):
        if root is None:
            return 
        for child in chirdren:
            print(f"从节点 {root} 进入节点 {child}")
            traverse(child)
            print(f"从节点 {child} 回到节点 {root}")
